package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 新增菜品
     * @param dish
     * @return
     */
    @AutoFill(OperationType.INSERT)
    int saveDish(Dish dish);

    List<DishVO> list(Dish dish);

    int queryCountByStatus(Integer status, List<Long> ids);

    int deleteByIds(List<Long> ids);

    DishDTO queryDishById(Long id);

    List<DishFlavor> queryDishFlavorByDishId(Long id);

    @AutoFill(OperationType.UPDATE)
    int updateDishStatus(Dish dish);

    @AutoFill(OperationType.UPDATE)
    int updateDish(Dish dish);

    List<DishItemVO> queryDishItemVoList(Long setmealId);

    List<Long> queryCategoryIdByIds(List<Long> ids);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

}
